<?php
// +----------------------------------------------------------------------
// | Cumulus(3D标签云
// +----------------------------------------------------------------------
// | @link ( http://www.yurnero.net )
// +----------------------------------------------------------------------
// | @copyright
// +----------------------------------------------------------------------
// | @licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | @author Haijun Wu <nicholasinlove@126.com>
// +----------------------------------------------------------------------
// | $Id: CumulusWidget.class.php 101 2011-04-22 10:10:57Z nicholasinlove1986@gmail.com $
// +----------------------------------------------------------------------


class CumulusWidget extends Widget {

	/**
	 * 构造标签云
	 * 
	 */
	public function render($data) {
	
		$tags  =  f_static_cache('tag_static','',ROOT_PATH . STATIC_CACHES_DIR);
		/* 标签着色,字体大小,加粗 */
		tag_cloud($tags);
		/* 3D标签云 */
		$xml = build_tag($tags);
	    $output = '';
		$output .= '<!-- Cumulus: START -->'."\n";
		$output .= " <script type=\"text/javascript\" src=\"__PUBLIC__/Plugins/cumulus/swfobject.js\"></script>\n";
		$output .= " <li class=\"widget widget_cumulus dbx-box\">\n";
		$output .= "  <h3 class=\"dbx-handle\">Tags</h3>\n";
		$output .= "   <div id=\"cumulus\" class=\"dbx-content\">\n";
		$output .= "    <p>\n";
		foreach ($tags as $k=>$v) {
			$output	.= "     <a href=\"".__APP__."/Tag/".$v['tag_url']."/\" class=\"tag-link-".$v['tag_id']."\" title=\"".$v['posts_num']." topics\" style=\"font-size:".$v['size']."; color:".$v['color'].";\">";
			if ($v['bold']) {
				$output	.= "<b>".$v['tag_name']."</b></a>\n";
			} else {
				$output	.= $v['tag_name']."</a>\n";
			}
		}
		$output .= "   </p>\n";
		$output .= "   <p><a href=\"http://www.adobe.com/go/getflashplayer\"><img src=\"http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif\" alt=\"Get Adobe Flash player\" /></a></p>\n";
		$output .= "  </div>\n";
		$output .= ' <script type="text/javascript">var tags_cloud = new SWFObject("__PUBLIC__/Plugins/cumulus/tagcloud.swf", "tagcloudflash", "'.C('cumulus_width').'", "'.C('cumulus_height').'", "9", "#ffffff");tags_cloud.addParam("wmode", "'.C('cumulus_wmode').'");tags_cloud.addParam("allowScriptAccess", "always");tags_cloud.addVariable("tcolor", "'.C('cumulus_tcolor').'");tags_cloud.addVariable("tcolor2", "'.C('cumulus_tcolor2').'");tags_cloud.addVariable("hicolor", "'.C('cumulus_hicolor').'");tags_cloud.addVariable("tspeed", "'.C('cumulus_tspeed').'");tags_cloud.addVariable("mode", "tags");tags_cloud.addVariable("tagcloud", "'.$xml.'");tags_cloud.write("cumulus");</script>';
		$output .= " </li>\n";
		$output .= ' <!-- Cumulus: END -->'."\n";

		return $output;
	}

}

?>